package com.qeng.aiwanba.util;

import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.util.Log;

/**
 * Created by Administrator on 2015/8/13.
 */
public class DownloadReceiver extends BroadcastReceiver implements Thread.UncaughtExceptionHandler {
    private Context context;
    @Override
    public void onReceive(final Context context, Intent intent) {
        this.context = context;
        Thread.setDefaultUncaughtExceptionHandler(this);
        if (intent.getAction().equals("com.aiwanba.broadcast.download_complete")) {
            //安装
            Log.e("tag","donwload complete");

        }else if(intent.getAction().equals("com.aiwanba.broadcast.download_progress")){
            //下载进度
//            Log.e("tag","progeress:"+DownloadUtil.getProgressValue(context,intent.getStringExtra("packageName")));
            DownloadUtil.getDownloadTask(context,"com.aiwanba.testdownload");
        }
    }

    @Override
    public void uncaughtException(Thread thread, Throwable ex) {
        ex.printStackTrace();
    }
}
